package com.thinkcube.edutainment;

import org.androidannotations.annotations.EActivity;

import android.app.Activity;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.Window;

import com.bugsense.trace.BugSenseHandler;
import com.thinkcube.edutainment.domain.data.LessonData;
import com.thinkcube.edutainment.domain.dto.PaymentDto;
import com.thinkcube.edutainment.fragment.PaymentConfrimationFragment;
import com.thinkcube.edutainment.fragment.PaymentConfrimationFragment_;

@EActivity
public class BuyLessonActivity extends Activity {
	
	LessonData lesson;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		BugSenseHandler.initAndStartSession(BuyLessonActivity.this,
				EdutainmentConstant.BUG_SENSE_APIKEY);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.buy_lesson);
		getWindow().setBackgroundDrawableResource(R.drawable.buy_lesson_border);
		
		
		
		if(getIntent().hasExtra("lessonObject"))
		{
			lesson=getIntent().getParcelableExtra("lessonObject");
			System.out.println("LESSON PRICE >>>"+lesson.getLessonPrice());
		}
		
		addPayementDetailFragment();
	}
	

	
	void addPayementDetailFragment()
	{
		PaymentDto paymentDto=new PaymentDto();
		FragmentTransaction fragmentTransaction = getFragmentManager()
				.beginTransaction();
		Bundle bundle = new Bundle();
		//paymentDto.setCouponId(coupon.getText().toString());
		//bundle.putParcelable("paymentData", paymentData);
		paymentDto.setPaymentPlan("1");
		bundle.putParcelable("paymentDto", paymentDto);
		bundle.putParcelable("lessonObject", lesson);
		bundle.putString("mode", "Full Payment");
		//bundle.putString("plan", );
		//bundle.putString("#installment", pInstallment.getText().toString());
		bundle.putString("price", lesson.getLessonPrice());
		bundle.putString("type", "lesson");
		PaymentConfrimationFragment paymentplan = new PaymentConfrimationFragment_();
		paymentplan.setArguments(bundle);
		fragmentTransaction.replace(R.id.payment_details, paymentplan);
		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.commit();
	}
	
	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();

		BugSenseHandler.closeSession(BuyLessonActivity.this);
	}

	
}
